package hibernateDao;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import entity.*;

public class HibernateUtil {
	private static final SessionFactory sessionFactory;
	static {
		try {
			AnnotationConfiguration config = new AnnotationConfiguration();

			config.addAnnotatedClass(Telefono.class);
			config.addAnnotatedClass(Particular.class);
			config.addAnnotatedClass(Celular.class);
			config.addAnnotatedClass(Comercial.class);
			config.addAnnotatedClass(Transaccion.class);
			config.addAnnotatedClass(Extraccion.class);
			config.addAnnotatedClass(Deposito.class);
			config.addAnnotatedClass(CajaAhorro.class);
			config.addAnnotatedClass(CuentaCte.class);
			config.addAnnotatedClass(Cuenta.class);
			config.addAnnotatedClass(Usuario.class);
			
			sessionFactory = config.buildSessionFactory();
			
		} catch (Throwable ex) {
			System.err.println("Initial SessionFactory creation failed." + ex);
			throw new ExceptionInInitializerError(ex);
		}
	}

	public static SessionFactory getSessionFactory() {
		return sessionFactory;
	}
}
